function ValidForm_new(el,opts,errorPlacementFn,submitHandlerFn,successFn,otherFn){
	//{args:['mobile'],errorElement:"span"}
	//
	var rules = {};
	var messages = {};
	for(var i=0,len=opts.args.length;i<len;i++){
		var b = opts.args[i];
		rules[b] = {};
		messages[b] = {};
		for(var c in this.validRM[b]){
			rules[b][c] = this.validRM[b][c]['rule'];
			messages[b][c] = this.validRM[b][c]['msg'];
		}
	}
		
	errorPlacementFn = errorPlacementFn || function(){};
	submitHandlerFn = submitHandlerFn || function(){};
	successFn = successFn || function(){};
	if(otherFn!=undefined){
		otherFn.call(null,rules,messages);
	}
	$(el).validate({
		rules:rules,
		messages:messages,
		errorElement:opts.errorElement||'em',
		errorPlacement:function(error,element){
			errorPlacementFn.call(null,error,element);
		},
	    success:function(label){
	    	successFn.call(null,label);
	    },  
	    submitHandler:function(form,event,validator){
	    	submitHandlerFn.call(null,form,event,validator);
	    } 
	});
}

/*所有key按顺序排列*/
$.ajax({
	url:"/themes/theme_default/media/js/common/valid.json",
	async:true,
	success:function(data){
		ValidForm_new.prototype.validRM = eval("("+data+")");
	}
})

function formSubmit_new(form,sucFn1,sucFn2){
	sucFn1 = sucFn1 || {};
	sucFn2 = sucFn2 || sucFn1;
	$(form).ajaxSubmit({
		dataType:'json',
		success:function(data){
			//单点登录检测
			//if(Auth.checkLogin(arguments[0]) == false) {return ;}
			if(data.result){
				sucFn1.call(null,data);
			}else{
				sucFn2.call(null,data);
			}
		}
	});
}

//1失败提示，2成功提示, 3等待提示
//配合form使用
function layer_new(form,type,options,cancelFn){
	var html = "";
	if(type==1){
		html = '<div class="tipsWrap w384"><div class="tipsTxt"><i class="iconfont errIco">&#xe63e;</i><span>'+options.msg+'</span></div><div class="tipsBtnBar"><a href="javascript:;" class="okBtn failBtn">确定</a></div></div>';                                       	
	}else if(type==2){
		html = '<div class="tipsWrap w384"><div class="tipsTxt"><i class="iconfont okIco">&#xe63d;</i><span>'+options.msg+'</span></div><div class="tipsMsg">3秒后窗口自动关闭</div></div>';
	}else if(type==3){
		html = '<div id="tips"><div class="tipsWrap w384"><div class="tipsTxt"><span>'+options.msg+'</span></div></div></div>';
	}else if(type==4){
		html = '<div class="tipsWrap w384"><div class="tipsTxt"><i class="iconfont tipIco">&#xe63c;</i><span>'+options.msg+'</span></div><div class="tipsBtnBar"><a href="javascript:;" class="okBtn okBtn_unbind">确认</a><a href="javascript:;" class="cancleBtn">取消</a></div></div>';
	}	
	
	if(options.closeBtn==undefined){
		options.closeBtn = 1;
	}
	cancelFn = cancelFn || function(){};
	
	layer.open({
         type: 1,
         closeBtn:options.closeBtn,
         time:options.time||0,
         title: "&nbsp;",
         area: ['384px', '186px'],
         border: [1, 1, '#cecfd0'],
         content:html,
         cancel: function (index) {
             if(type==1){
            	 layer.closeAll();
             }else{
            	 cancelFn.call(null);
             }           	 
         },
         end: function(){
        	 cancelFn.call(null);
         },
         success:function(layero){
        	 if(type==2){
            	 var time =3; 
		    	 function closeTime () {
					 time--;
					 $(".tipsMsg").html(time+"秒后窗口自动关闭");
				 }
		    	 setInterval(function() {
		    		 closeTime();
		    	 }, 1000);
        	 }
         }
     });
	 $(".failBtn,.cancleBtn").unbind('click').click(function(){
         layer.closeAll();
     });
}

function getCodeTime_new(o){
	
}

function clickSend_new(args,sucFn1,sucFn2){
	sucFn1 = sucFn1 || {};
	sucFn2 = sucFn2 || sucFn1;
	for(var i=0,len=args.length;i<len;i++){
		(function dd(index){
			$(args[index].el).click(function(){
		 		var o = this;
		 		$.ajax({
		 			url:args[index].url,
		 			type:'post',
		            dataType:'json',
		 			success:function(data){
		 				if(data.result){
		 					sucFn1.call(null,o);
		 				}else {
		 					sucFn2.call(null,data);
		                }
		 			}
		 		});
		 	});
		})(i);
		
	}
	
	
}

